using System;
using Microsoft.Xna.Framework.Graphics;

namespace HOPE
{
    /// <summary>
    /// Represents an animated texture.
    /// </summary>
    /// <remarks>
    /// Currently, this class assumes that each frame of animation is
    /// as wide as each animation is tall. The number of frames in the
    /// animation are inferred from this.
    /// </remarks>
    
    class Animation
    {
        /// <summary>
        /// Seluruh frame dalam animasi disusun secara horizontal.
        /// </summary>
        public Texture2D Texture
        {
            get { return texture; }
        }
        Texture2D texture;

        /// <summary>
        /// durasi waktu untuk menampilkan tiap frame-nya
        /// </summary>
        public float FrameTime
        {
            get { return frameTime; }
        }
        float frameTime;

        /// <summary>
        /// ketika animasi telah sampai pada frame terakhir
        /// dia akan ngeloop lagi dari awal
        /// </summary>
        public bool IsLooping
        {
            get { return isLooping; }
        }
        bool isLooping;

        /// <summary>
        /// buat ngitung frame dalam animasinya
        /// </summary>
        public int FrameCount
        {
            get { return Texture.Width / FrameWidth; }
        }
        
        /// <summary>
        /// buat ngitung lebar frame animasinya
        /// </summary>
        public int FrameWidth
        {
            //asumsikan framenya kotak
            get { return Texture.Height; }
        }

        /// <summary>
        /// buat ngitung tinggi frame animasinya
        /// </summary>
        public int FrameHeight
        {
            get { return Texture.Height; }
        }

        /// <summary>
        /// contruct animasi baru
        /// </summary>
        public Animation(Texture2D texture, float frameTime, bool isLooping)
        {
            this.texture = texture;
            this.frameTime = frameTime;
            this.isLooping = isLooping;
        }
    }
}
